<template>
<h1>猜数字</h1>
  <input type="text" placeholder="请输入1~100之间的整数" v-model="num">
  <button @click="guess()">猜一猜</button>
  <h3>{{result}}</h3>
</template>
<script setup>
import {ref} from "vue";

let r=parseInt( Math.random()*100)+1
console.log('打个小抄'+r);
const num=ref('');
const result=ref('');
const guess = () =>{
  if (num.value > r){
    result.value='猜大了'
  }else if(num.value<r){
    result.value='猜小了'
  }else {
    result.value='猜对了'
  }
}

</script>

<style scoped>

</style>